{{ define "title" }}{{ .Title }}{{ end }}

{{ define "css" }}

{{ if .Site.Params.highlightjs }}
{{ if .Site.Params.highlightjsTheme }}
<link rel="stylesheet" data-highlight href="https://shenmo7192.gitee.io/cdn-release/build/styles/{{ .Site.Params.highlightjsTheme }}.min.css" />
{{ else }}
<link rel="stylesheet" data-highlight href="https://shenmo7192.gitee.io/cdn-release/build/styles/default.min.css" />
{{ end }}
{{ end }}

{{ if .Site.Params.valine }}
<script src='//unpkg.com/valine/dist/Valine.min.js'></script>
{{ end }}

{{ end }}

{{ define "main" }}
<div class="ui relaxed centered grid dream-grid dream-grid-single"{{ if .Site.Params.reversePostAndAside }}style="flex-direction: row-reverse;"{{ end }}>
  <!-- len <nav id="TableOfContents"></nav> == 32 -->
  {{ $showTOC := ge (len .TableOfContents) 33 }}
  {{ $shareInAside := .Site.Params.shareInAside }}
  {{ $showAside := or $showTOC $shareInAside }}

  {{ if $showAside }}
  <aside class="sixteen wide mobile sixteen wide tablet three wide computer column dream-single-aside">
    {{ if $showTOC }}
    <div class="ui segment toc">
      {{ .TableOfContents }}
    </div>
    {{ end }}

    {{ if $shareInAside }}
    {{ partial "share1.html" . }}
    {{ end }}
  </aside>
  {{ end }}
  <div class="sixteen wide mobile sixteen wide tablet ten wide computer column markdown-body dream-single" id="dream-save-post-as-img">
    <section class="ui top attached segment">
      <header>
        <h1 class="ui large header">
          {{- .Title -}}
          <span class="sub header">
            <span class="left">
              @
              {{ if isset .Params "author" }}
                {{ if isset .Params "authorlink" }}
                  <a href="{{ .Params.authorlink }}" target="_blank">{{ .Params.author }}</a>
                {{ else }}
                  {{ .Params.author }}
                {{ end }}
              {{ else }}
                {{ .Site.Params.author }}
              {{ end }}

              | {{ if .Site.Params.Experimental.jsDate }}
                  <span data-format="luxon">{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}</span>
                {{ else }}
                  {{ if eq .Site.Language.Lang "zh" }}
                    {{ index .Site.Data.zh.Weekday (printf "%d" .Date.Weekday) }}，{{ index .Site.Data.zh.Month (printf "%d" .Date.Month) }} {{ .Date.Day }} 日，{{ .Date.Year }} 年
                  {{ else if eq .Site.Language.Lang "es" }}
                    {{ index .Site.Data.es.Weekday (printf "%d" .Date.Weekday) }}, {{ .Date.Day }} de {{ index .Site.Data.es.Month (printf "%d" .Date.Month) }} de {{ .Date.Year }}
                  {{ else if eq .Site.Language.Lang "pt" }}
                    {{ index .Site.Data.pt.Weekday (printf "%d" .Date.Weekday) }}, {{ .Date.Day }} de {{ index .Site.Data.pt.Month (printf "%d" .Date.Month) }} de {{ .Date.Year }}
                  {{ else if eq .Site.Language.Lang "fr" }}
                    {{ index .Site.Data.fr.Weekday (printf "%d" .Date.Weekday) }} {{ .Date.Day }} {{ index .Site.Data.fr.Month (printf "%d" .Date.Month) }} {{ .Date.Year }}
                  {{ else }}
                    {{ .Date.Format "Monday, Jan 2, 2006" }}
                  {{ end }}
                {{ end }}

              | {{ .ReadingTime }}{{ i18n "minuteRead" .ReadingTime }}

              {{ if ne .Params.nolastmod true }}
              | {{ i18n "updateAt" }}
                {{ if .Site.Params.Experimental.jsDate }}
                  <span data-format="luxon">{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}</span>
                {{ else }}
                  {{ if eq .Site.Language.Lang "zh" }}
                    {{ index .Site.Data.zh.Weekday (printf "%d" .Lastmod.Weekday) }}，{{ index .Site.Data.zh.Month (printf "%d" .Lastmod.Month) }} {{ .Lastmod.Day }} 日，{{ .Lastmod.Year }} 年
                  {{ else if eq .Site.Language.Lang "es" }}
                    {{ index .Site.Data.es.Weekday (printf "%d" .Lastmod.Weekday) }}, {{ .Lastmod.Day }} de {{ index .Site.Data.es.Month (printf "%d" .Lastmod.Month) }} de {{ .Lastmod.Year }}
                  {{ else if eq .Site.Language.Lang "pt" }}
                    {{ index .Site.Data.pt.Weekday (printf "%d" .Lastmod.Weekday) }}, {{ .Lastmod.Day }} de {{ index .Site.Data.pt.Month (printf "%d" .Lastmod.Month) }} de {{ .Lastmod.Year }}
                  {{ else if eq .Site.Language.Lang "fr" }}
                    {{ index .Site.Data.fr.Weekday (printf "%d" .Date.Weekday) }} {{ .Date.Day }} {{ index .Site.Data.fr.Month (printf "%d" .Date.Month) }} {{ .Date.Year }}
                  {{ else }}
                    {{ .Lastmod.Format "Monday, Jan 2, 2006" }}
                  {{ end }}
                {{ end }}
              {{ end }}
            </span>

            {{ if not $shareInAside }}
            {{ partial "share.html" . }}
            {{ end }}
          </span>
        </h1>
      </header>

      <article class="main">
        {{ if and .Params.Cover .Site.Params.showSummaryCoverInPost }}
        <img class="cover" src="{{ .Params.Cover }}" />
        {{ end }}

        {{ .Content | emojify }}
      </article>
    </section>

    {{ if .Site.DisqusShortname }}
    <article class="ui segment post-disqus-area" data-html2canvas-ignore>
      {{ partial "disqus.html" (dict "Context" . "Identifier" .RelPermalink) }}
    </article>
    {{ end }}

    {{ if .Site.Params.utterancesRepo }}
    <article class="ui segment utterances-comments" data-html2canvas-ignore>
      <script
        src="https://utteranc.es/client.js"
        repo="{{ .Site.Params.utterancesRepo }}"
        issue-term="og:title"
        theme="github-light"
        crossorigin="anonymous"
        async>
      </script>
    </article>
    {{ end }}

    {{ if .Site.Params.valine }}
    <article class="ui segment" data-html2canvas-ignore>
      <div id="vcomments"></div>
    </article>

    <script>
      new Valine({
        el: '#vcomments',
        appId: {{ .Site.Params.LEANCLOUD_APP_ID }},
        appKey: {{ .Site.Params.LEANCLOUD_APP_KEY }},
        lang: {{ .Site.Params.VALINE_LANGUAGE }}
      })
    </script>
    {{ end }}
  </div>
</div>
{{ end }}

{{ define "js" }}

{{ if .Site.Params.Experimental.jsDate }}
<script src="https://unpkg.com/luxon@1.26.0"></script>

{{ partial "luxon.html" . }}
{{ end }}

<script src="{{ "/js/scrollToTop.js" | relURL }}"></script>

{{ if .Site.Params.highlightjs }}
<script src="{{ if .Site.Params.highlightjsCDN }}{{ .Site.Params.highlightjsCDN }}{{ else }}{{ "https://shenmo7192.gitee.io/cdn-release/build/highlight.min.js" }}{{ end}}"></script>

{{ if .Site.Params.highlightjsExtraLanguages }}
{{ range .Site.Params.highlightjsExtraLanguages }}
<script src="https://shenmo7192.gitee.io/cdn-release/build/languages/{{ . }}.min.js"></script>
{{ end }}
{{ end }}

{{ partial "highlight.html" . }}
{{ end }}

<script src="https://unpkg.com/html2canvas@1.0.0-rc.1"></script>
<script src="{{ "/js/post.js" | relURL }}" defer></script>
{{ end }}
